﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddEdit.aspx.cs" Inherits="CardLogistics.Web.MainPage.CardArrival.StorageInventory.AddEdit" %>
<%@ Register Src="../../../Controls/WebUserControl_Nav.ascx" TagName="WebUserControl_Nav"
    TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>库存盘点-编辑</title>
    <link href="../../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/selPage.css" rel="stylesheet" type="text/css" />
    <script src="../../../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../../../js/valReq.js" type="text/javascript"></script>
    <script src="../../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../../js/jquery.tipswindow.2.0.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        function valReq(issubmit) {
            var altStr = valid_isempty('DEMANDNO', '需求单号');
            altStr += valid_isempty('APPLICANT', '申请人');
            altStr += valid_isempty('APPLICADATE', '申请日期');
            altStr += valid_isempty('CARDDATE', '需卡日期');
            altStr += GetCardInfo();
            altStr += valid_isempty('hf_ConId', '卡数量');
            if (altStr != "") {
                alert(altStr);
                return false;
            }
            else {
                if (issubmit == 1) {
                    if (confirm("提交后该信息进入待审批状态不可编辑,确认提交吗?") == true) {
                        return true;
                    }
                    else
                        return false;
                }
                else
                    return true;
            }
        }
        function GetCardInfo() {
            var Data_value = [];
            var errInfo = ""; //返回错误消息
            var vIndex = 0;
            var cardNum = 0;
            var CardNumber = $("input[name=CardNumber]");
            $("select[name=CardType] option:selected").each(function (i, o) {
                if ($(CardNumber[i]).val() != "0" && $(CardNumber[i]).val() != "") {
                    Data_value[vIndex] = Trim($(o).val()) + "|" + Trim($(CardNumber[i]).val()); //类型ID+数量
                    cardNum += parseInt(Trim($(CardNumber[i]).val()));
                    vIndex++;
                    if (Trim($(o).text()) == "")
                        errInfo += "请给第" + vIndex + "行选择卡类型！\n";
                }
            });
            $("#hf_ConId").val(Data_value.join(";"));
            return errInfo;
        }

        $(document).ready(function () {    //
            $("input[name='CardNumber']").keyup(function () {

                var cNumber = $("input[name=CardNumber]");
                var csum = 0;
                $("select[name=CardType] option:selected").each(function (i, o) {
                    if ($(cNumber[i]).val() != "0" && $(cNumber[i]).val() != "") {
                        csum += parseInt(Trim($(cNumber[i]).val()));
                        if (Trim($(o).text()) == "") {
                            $(o).focus();
                        }
                    }
                });
                document.getElementById("tsum").innerHTML = csum;
            });
        });
        function BindDetailInfo() {
            var csum = 0;
            var cNumber = $("input[name=CardNumber]");
            var cType = $("select[name=CardType]");
            var ids = document.getElementById("hf_ConId").value;
            var str1 = ids.split(";");
            for (var i = 0; i < str1.length; i++) {
                if (str1[i] != "") {
                    $(cNumber[i]).val(str1[i].split("|")[1]);
                    $(cType[i]).val(str1[i].split("|")[0]);
                    csum += parseInt(str1[i].split("|")[1]);
                }
            }
            document.getElementById("tsum").innerHTML = csum;
        }
        window.onload = function () { BindDetailInfo(); }  
    </script>
</head>
<body>
    <form id="frmFather" runat="server">
    <uc1:WebUserControl_Nav ID="WebUserControl_Nav1" runat="server" />
   <%=TitleName %> <input type="hidden" id="hf_ConId" name="hf_ConId" runat="server" />
    <table class="theForm" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="titleTxt">
                需求单号：
            </td>
            <td class="contentTxt">
                <input id="DEMANDNO" runat="server" type="text" class="dfinputNoEmp" />
            </td>
            <td class="titleTxt">
                申请人：
            </td>
            <td class="contentTxt">
                <input id="APPLICANT" runat="server" type="text" class="dfinputNoEmp" />
            </td>
        </tr>
         <tr>
            <td class="titleTxt">
                用卡机构：
            </td>
            <td colspan="3">
                <input id="CARDMECHANISM" runat="server" type="text" class="dfinput" style="width: 90%;" />
            </td>
        </tr>
        <tr>
            <td class="titleTxt">
                申请日期：
            </td>
            <td class="contentTxt">
                <input id="APPLICADATE" runat="server" type="text" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
            </td>
            <td class="titleTxt">
                需卡日期：
            </td>
            <td class="contentTxt">
                <input id="CARDDATE" runat="server" type="text" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
            </td>
        </tr>
        <tr>
            <td class="titleTxt">
                备注：
            </td>
            <td colspan="3">
                <input id="REMARKS" runat="server" type="text" class="dfinput" style="width: 90%;" />
            </td>
        </tr>
         <tr>
            <td colspan="4">
                <div class="ddetail" style="height: 270px;">
                    <table class="tabledetail" id="tb_Detail">
                        <thead>
                            <tr>
                                <th>
                                    序号
                                </th>
                                <th>
                                    卡片类型
                                </th>
                                <th>
                                    数量
                                </th>
                                <th>
                                    &nbsp;
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="70px" align="center">
                                    1
                                </td>
                                <td width="280px">
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td width="150px">
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7" />
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td width="70px" align="center">
                                    2
                                </td>
                                <td>
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td>
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7">
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td width="70px" align="center">
                                    3
                                </td>
                                <td>
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td>
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7" />
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td width="70px" align="center">
                                    4
                                </td>
                                <td>
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td>
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7" />
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td width="70px" align="center">
                                    5
                                </td>
                                <td>
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td>
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7" />
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td width="70px" align="center">
                                    6
                                </td>
                                <td>
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td>
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7" />
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td width="70px" align="center">
                                    7
                                </td>
                                <td>
                                    <select name="CardType">
                                        <option value="0"></option>
                                        <%foreach (var CardType in CardTypeList)
                                          {%>
                                        <option value="<%=CardType.Key %>">
                                            <%=CardType.Value %></option>
                                        <% }%>
                                    </select>
                                </td>
                                <td>
                                    <input name="CardNumber" type="text" value="0" onkeydown="onlyNum();" maxlength="7" />
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <table class="tablesum">
                    <tr>
                        <td width="70px">
                        </td>
                        <td width="280px">
                            合计
                        </td>
                        <td width="150px" id="tsum" style="text-align: right">
                            0
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr class="btntr">
            <td colspan="4" align="center">
                <asp:Button ID="btn_Submit" CssClass="btn" runat="server" Text="保存并提交" OnClientClick="return valReq(1);"
                     OnClick="btn_Submit_Click"  />
                <asp:Button ID="btn_Add" CssClass="btn" runat="server" Text="保存" OnClientClick="return valReq(0);"
                 OnClick="btn_Add_Click"  />
                <input type="button" class="btn" value="返回" onclick="javascript:history.go(-1);" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>